

public class TestVolatile {
    public static int i = 0;

    public static void main(String[] args) {
        for (int x = 0; i < 10; i++) {
            new Thread() {
                public void run() {
                    for (int y = 0; y < 1000; y++) {
                        i++;
                    }
                }
            }.run();
        }
        System.out.println(i);
    }
}
